<template>
  <ma-crud ref="crudRef" :columns="columns" :options="crud">
    <template #search-title="{ searchForm, component }">
      <a-input v-model.trim="searchForm[component.dataIndex]" :style="{ width: '240px' }" allow-clear placeholder="请输入标题">
        <template #prefix>
          <icon-search />
        </template>
      </a-input>
    </template>
    <template #tableBeforeButtons="{ record }">
      <a-button v-hasPermi="['system:announcement:edit']" type="primary">全部已读</a-button>
    </template>
    <template #operationAfterExtend="{ record }">
      <a-link @click="handleSee(record)">查看</a-link>
    </template>
  </ma-crud>
</template>
<script lang="ts" setup>
import { listMyAnnouncement } from "@/api/monitor/announcementSend";

const crud = reactive({
  id: "id",
  pk: "id",
  title: "消息查询",
  api: listMyAnnouncement,
  showIndex: false,
  operationColumn: true,
  operationColumnAlign: "center",
  operationColumnWidth: 150,
  pageLayout: "normal"
});

const columns = reactive([
  {
    title: "编号",
    dataIndex: "id",
    addDisplay: false,
    editDisplay: false,
    hide: true
  },
  {
    title: "公告ID",
    dataIndex: "antId",
    addDisplay: false,
    editDisplay: false,
    hide: true
  },
  {
    title: "标题",
    dataIndex: "title",
    addDisplay: false,
    editDisplay: false,
    search: true
  },
  {
    title: "消息类型",
    dataIndex: "msgCategory",
    formType: "radio",
    align: "center",
    dict: {
      name: "sys_notice_type",
      cache: true,
      props: { label: "dictLabel", value: "dictValue" },
      translation: true,
      tagColors: true
    },
    addDefaultValue: 1
  },
  {
    title: "发布人",
    dataIndex: "senderName",
    align: "center",
    addDisplay: false,
    editDisplay: false
  },
  {
    title: "发布时间",
    dataIndex: "sendTime",
    align: "center",
    addDisplay: false,
    editDisplay: false
  },
  {
    title: "优先级",
    dataIndex: "priority",
    formType: "radio",
    align: "center",
    dict: {
      name: "sys_notice_priority_type",
      cache: true,
      props: { label: "dictLabel", value: "dictValue" },
      translation: true,
      tagColors: true
    },
    addDefaultValue: 0
  },
  {
    title: "阅读状态",
    dataIndex: "readFlag",
    align: "center",
    addDisplay: false,
    editDisplay: false,
    formType: "radio",
    dict: {
      name: "sys_notice_read_type",
      cache: true,
      props: { label: "dictLabel", value: "dictValue" },
      translation: true,
      tagColors: true
    },
    addDefaultValue: 0
  }
]);

const handleSee = (row: any) => {};
</script>
